package com.joshua.viewtest.demo.ElevationAndShadow;

import android.os.Build;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.MotionEvent;
import android.view.View;
import android.widget.ImageView;

import com.joshua.viewtest.R;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnTouch;

public class ElevationAty extends AppCompatActivity {
    @BindView(R.id.circle)
    ImageView view1;

    @Override
    protected void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_elevation);
        ButterKnife.bind(this);
    }

    @OnTouch({R.id.circle, R.id.rectangle})
    public boolean onViewTouch(View v, MotionEvent e) {
        if (v.getId() == R.id.circle) {
            switch (e.getAction()) {
                case MotionEvent.ACTION_DOWN:
                    if (Build.VERSION.SDK_INT >= 21)
                        view1.setTranslationZ(-120);
                    break;
                case MotionEvent.ACTION_UP:
                    if (Build.VERSION.SDK_INT >= 21)
                        view1.setTranslationZ(0);
                    break;
                default:
                    return false;
            }
        }
        return true;
    }
}
